package database_interaction;

/**
 * @file DeleteQuery.java
 * @version 0.1
 * @author James Dibble 10009689
 */
public class DeleteQuery extends SQLQuery{
    // <editor-fold defaultstate="collapsed" desc="Attributes">
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructors">
    public DeleteQuery(String table) {
        super(QueryType.DELETE, table);
    }
    
    public DeleteQuery(String table, String filter) throws JDBCException {
        super(QueryType.DELETE, table);
        super.setFilter(filter);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Methods">
    @Override
    public String getQueryString() throws JDBCException {
        if(super.getFilter() == null || "".equals(super.getFilter()))
            throw new JDBCException("A delete query MUST have a filter.");
        return String.format("DELETE FROM %s WHERE %s",
                             super.getTable(),
                             super.getFilter());
    }
    // </editor-fold>

    
}